Two flavors of Python decorators:

  • Function decorators
  • Class decorators

Roles

Wrapper/Proxy objects

  • Call proxies
  • Interface proxies

Managing Functions and Classes

  • Function managers
  • Class managers

Python built-in decorators

  • static, class method declarations
  • property creation

Typical use cases

Function decorators

  • call tracing, logging, profiling
  • argument validity testing
  • automatical lock aquiring/releasing

Class decorators

  • trace, validate etc. attribute references made to an object
  • proxy objects
  • singleton classes

In [ ]: